/**
 * Created by luchengdong on 2017/8/28.
 */

function $(id) {
    // 类型的比较
    return typeof id === 'string' ? document.getElementById(id) : id;
}

window.onload = function () {
    var li_list = $('tab-list').getElementsByTagName('li');
    var content_list = $('content').getElementsByClassName('dom');
    if (li_list.length != content_list.length) {
        return;
    }

    for (var i = 0; i < li_list.length; i++) {
        var li = li_list[i];
        li.id = i;

        li.onmousemove = function () {

            for (var j = 0; j < li_list.length; j++) {
                li_list[j].className = '';
                content_list[j].style.display = 'none';
            }

            this.className = 'current-tab';
            content_list[this.id].style.display = 'block';
        }
    }

}